#include <Control.h>

Control::Control() : QWidget()
{
	up = new QPushButton();
	down = new QPushButton();

	forward = new QPushButton();
	backward = new QPushButton();
	left = new QPushButton();
	right = new QPushButton();

	rotate_left = new QPushButton();;
	rotate_right = new QPushButton();;

	set_img(up, "images/up.png");
	set_img(down, "images/down.png");

	set_img(forward, "images/up.png");
	set_img(backward, "images/down.png");
	set_img(left, "images/left.png");
	set_img(right, "images/right.png");

	set_img(rotate_left, "images/rotate_left.png");
	set_img(rotate_right, "images/rotate_right.png");

	QGridLayout *layout = new QGridLayout;
	layout->addWidget(up, 0, 0);
	layout->addWidget(down, 3, 0);

	layout->addWidget(forward, 0, 2);
	layout->addWidget(backward, 2, 2);
	layout->addWidget(left, 1, 1);
	layout->addWidget(right, 1, 3);

	layout->addWidget(rotate_left, 3, 1);
	layout->addWidget(rotate_right, 3, 3);

	setLayout(layout);

	
	QObject::connect(forward, SIGNAL(clicked()), this, SLOT(handler_forward()));
	QObject::connect(backward, SIGNAL(clicked()), this, SLOT(handler_backward()));
	QObject::connect(left, SIGNAL(clicked()), this, SLOT(handler_left()));
	QObject::connect(right, SIGNAL(clicked()), this, SLOT(handler_right()));
	QObject::connect(up, SIGNAL(clicked()), this, SLOT(handler_up()));
	QObject::connect(down, SIGNAL(clicked()), this, SLOT(handler_down()));
	QObject::connect(rotate_left, SIGNAL(clicked()), this, SLOT(handler_rotate_left()));
	QObject::connect(rotate_right, SIGNAL(clicked()), this, SLOT(handler_rotate_right()));
}

void Control::set_img(QPushButton* button, QString img_path)
{
	QImage image(img_path);
	button->setIcon(QIcon(img_path));
	button->setIconSize(image.size()); 
}


void Control::handler_forward()
{

}
void Control::handler_backward()
{

}
void Control::handler_left()
{

}
void Control::handler_right()
{

}

void Control::handler_up()
{

}
void Control::handler_down()
{

}

void Control::handler_rotate_left()
{

}

void Control::handler_rotate_right()
{

}
